<?php
/**
 * oscshop2 B2C电子商务系统
 *
 * ==========================================================================
 * @link      http://www.oscshop.cn/
 * @copyright Copyright (c) 2015-2017 oscshop.cn. 
 * @license   http://www.oscshop.cn/license.html License
 * ==========================================================================
 *
 * @author    李梓钿
 *
 */
namespace osc\admin\controller;
use osc\common\controller\AdminBase;
use think\Db;
class PluginSlide extends AdminBase{
	
	protected function _initialize(){
		parent::_initialize();
		$this->assign('breadcrumb1','扩展');
		$this->assign('breadcrumb2','轮播图');
	}

	public function index(){     	
		
		$list = Db::name('plugin_slide')->paginate(config('page_num'));
		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
		$this->assign('list', $list);
	
		return $this->fetch();

	 }
	 public	function add(){
		if(request()->isPost()){	
			return $this->single_table_insert('PluginSlide','添加了轮播图');
		}
		$this->assign('crumbs', '新增');
		$this->assign('action', url('PluginSlide/add'));
		return $this->fetch('edit');
	}
	 public	function edit(){
		if(request()->isPost()){	
			return $this->single_table_update('PluginSlide','修改了轮播图');
		}
		$this->assign('crumbs', '修改');
		$this->assign('action', url('PluginSlide/edit'));		
		$this->assign('d',Db::name('PluginSlide')->find(input('id')));		
		return $this->fetch('edit');
	}
	public	function del(){
		if(request()->isGet()){	
			$r= $this->single_table_delete('PluginSlide','删除了轮播图');
			if($r){
				$this->redirect('PluginSlide/index');
			}
		}
	}
	public function set_status(){		
		$data=input('param.');
		Db::name('PluginSlide')->where('slide_id',$data['id'])->update(['status'=>(int)$data['status']],false,true);
		storage_user_action(UID,admin('username'),config('BACKEND_USER'),'修改了用户组状态');
		$slide=Db::name('plugin_slide')->where(['status'=>1])->select();
		cache('plugin_slide', $slide);
		$this->redirect('PluginSlide/index');
	} 
}
?>